package com.tingyuge.base.thread.wang.chapter3;

import java.util.Arrays;

/**
 * Created by xiaodao
 * date: 2019/11/28
 */
public class CreateThread2 {
    public static void main(String[] args) {
        Thread thread = new Thread(){
            @Override
            public void run() {
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        };
        thread.start();
        thread.getThreadGroup();
//        System.out.println(thread.getThreadGroup().getName());
//        System.out.println(Thread.currentThread().getName());
//        System.out.println(Thread.currentThread().getThreadGroup());
        ThreadGroup threadGroup = Thread.currentThread().getThreadGroup();
        System.out.println(threadGroup.activeCount());
        Thread[] threads = new Thread[threadGroup.activeCount()];

        threadGroup.enumerate(threads);
        Arrays.asList(threads).forEach(System.out::println);
    }
}
